const User = require('../model/user.model')
class UserService {
    // 创建用户
    async createUser(userEmail, password) {
        const data = {
            userName: userEmail,
            password,
            userEmail
        }
        const newUser = await User.create(data)
        return newUser.dataValues
    }
    // 查询用户信息
    async getUserInfo({ ...args }) {
        const whereOpt = { ...args }
        const res = await User.findOne({
            attributes: ['id', 'userEmail', 'isAdmin', 'userName', 'password'],
            where: whereOpt
        })
        return res ? res.dataValues : null
    }
}

module.exports = new UserService()